<?php
	
	/**
	 * 管理员表model
	 */
	class AdminModel extends Model{
		/**
		 * 检测当前的用户是否为管理员
		 */
		public function getAdmin($aid){
			$model = M('admin');
			$admins = $model->query("SELECT * FROM hd_admin WHERE aid={$aid}");
			return current($admins);
		}
		
		/**
		 * 登陆时判断是否帐号密码错误 
		 */	
		 public function logincheck($username,$pwd){
		 	$model = M('admin');
			$admins = $model->query("SELECT * FROM hd_admin WHERE username='{$username}' AND passwd='{$pwd}'");
			return current($admins);
		 }
		 
		 
		 /**
		  * 写入IP写入登陆时间
		  */
		  public function writeIpTime($aid){
		  	$model = M('admin');
			$ip = getIp();
			$time = time();
			$admins = $model->_exec("UPDATE hd_admin SET loginip='{$ip}',logintime={$time} WHERE aid={$aid}");
			return $admins;		
		  }
		 
	}
